export default {
  mounted(el, binding) {
    function check() {
      if (el.scrollWidth > el.clientWidth) {
        el.setAttribute('title', binding.value || el.innerText);
      } else {
        el.removeAttribute('title');
      }
    }
    check();
    window.addEventListener('resize', check);
    el.__ellipsisCheck__ = check;
  },
  updated(el, binding) {
    el.__ellipsisCheck__ && el.__ellipsisCheck__();
  },
  unmounted(el) {
    window.removeEventListener('resize', el.__ellipsisCheck__);
    delete el.__ellipsisCheck__;
  }
}; 